more logging and better assertions