cleaned up database code, removed some references nonsense, updated phpdocs. refs #106 and #136