Fix some code style and a try/catch