Fixed a number of small issues.
Moved TreeAlias to a plain old table. Properly configured master_revision_id and some other foreign keys/relationships.
Sorted imports, because isort was complaining.
Fixed table/data creation scripts.