Add some logging and some assertions