Refactored and expanded rest api endpoints