Refactored to allow the app to live in arbitrary subdirectories.