Better logging and bugfixes for stupid bugs