Lots of refactoring. Wrapped global functions in object, determined required visibility. Some deprecated functions removal.