reorganized logging, cleaned up a bit