More proper ajax chaining

Not sure if this fixes anything but it was a race condition
Minor style quirk
Style quirks, kill dead code