Refactor so core only contains the main methods; all the rest put into utils.