Cleanup
Fix assertion
Simplify code