json_from_request() is not used anymore
No need for a copy of g.json
Minor refactoring to save an if

Using dict.pop() with a default value
Don't try to delete versions if it's not there
Switch to lazy formatting
Style fixes
Minor refactoring to simplify logic