Fixes #4 by adding transform middleware to routes. Also, code cleanup.