Logging

Added some logging stuff. Please have a look.