cleaned up database code, removed some references nonsense, updated phpdocs. refs #107 and #137