Removed returns that weren't used and added some try-catch blocks