Major refactoring and dependency updates