Fixes bugs with wrong save (update/insert)
Adds the code to work with PaaS AppFog