Properly sort array of integers

Otherwise we would end up randomly having units stored in wrong positions.
Allow specifying an arbitrary page for `fetchPages`
Moved context-specific data away from templates into settings
Use unit numbering instead of page numbering

Fixes bug 2215.
Use js-friendly property names
No need to disable async requests
Return 404 page if the directory does not exist
Missing bit from goals