bugfix: now uses the key and name elements of the POSTed JSON entity correctly
minor refactorings