Improved logging abilities, and added ability to switch off logging