Improve the API const-correctness