Altered the logger

If no (or invalid) logger level is passed, just display log as a generic
message, rather than throwing a semi-error
Started refactoring some clean up code

Created a generic cleanup() function which should be called when clean
up is required, especially in the event of a fatal error. This should
make things tidier