some cleaning up, refactoring and extending Rest / API functionality