Fixed issues raised in Jonny's code review