Asserts, logging and TODOs fixes