Change bindings, re-organize code, add tests