Added log messages, fixed some minor bugs