fix bugs, logging