Crude logger and bug fixes