Refactored and cleaned code
Updated API, breaks the web interface, sorry