More asserts and making the functions const