Further modularized code such that it can be mounted in another express app. Fixes #2.