Massive refactoring

Moved bootstrap code into Application class, changed config file from PHP to
YAML, improved error handling with exceptions, and clean a lot of code.