Fixed some code quality issues like no null checks.