Added some comments. Made database singleton.