Simplified a code construct
Move some stuff into libraries and create a logging class