Fix uncaught exception errors in Main.java