Refactor the init method and do some tidying