Fix bugs introduced when splitting up the file.
Make all ajax functions take a callback.