Cleanup

fixed the style issues @benbasson mentioned and moved the ajax part to a
separate method.