WIP: Logging, bug fixes