Refactoring, more robust XHR, more test cases, etc.