starting to refactor api layer, getting c/p stuff cleaned up