Make relative path for PHP-Egg database file. Import JSON module

Also a little code cleanup.