Major refactoring / enhancements.