fixed some bugs, cleaned up output and logging