Performance enhancements, refactoring, documentation