Finish debugging refactorings, improve logging aspect, fix minor errors