Work in progress refactor

 * API v5
 * Tests
 * Separation of concerns