Renames library classes and create a database handler.

Extracts code from models and add them into a base class.