Code cleanup

Renamed methods, added type annotations, cleaned up namespacing.