Refactor - reorganised functions and added //MARK documentation for pretty headers