Major refactoring and cleanup (breaking changes)