Cleaned up code and added feature to switch logging depending on a custom preprocessor flag