Close to getting everything compatible with GWT, a few refactorings