Add license header.
Factor out some routing handling functions.