UNTESTED: application creation and minor refacorings
return nil as the value if there is an error
fix some issues
UNTESTED: setting application keys