Improved logging and added new functions