database.php cleaned up a little bit, comments added
Cleaning up lib.php and adding comments