improved logging. fixed minor bugs.