Made main.php handle exceptions
Replaced all PEAR errors with PHP exceptions in Loris