refactor some things into utils and bring all apis up to spec