Move API to it's own module, fix #31
More work on #31