Added a better logging system using the logging module

All in one commit now.