Performance improvements for code, testability for callbacks