Added comments, null checks based on code review