Updated logging and main function