Basic draft of API and small fixes and refactoring of legacy code