Big refactor, minor improvements with some breaking changes