error cleanup, log cleanup, bug fixes