Refactor code

- Restructure code to remove the need for a mutex around the log call
- Remove the auto close functionality
- Only call openlog once in the initializer