Feature/api

Moving general methods to a new api module.

This is a start, I think it should be merged into dev frequently to keep review size down.

@arthurian please review