small fixes, added some asserts, nothing much worth noting