Big refactor

Stop doing as much text processing in Javascript, instead
it's now done on the server side.