Implemented logging
Bugfixes