Add some asserts and comments