Major implementation refactoring