Wip/api modules

Separate api into smaller separate modules, should make for easier testing.