code review and bugfixing