Updated for new database and refactored some stuff. Can probably remove chain class now.