Saving manual endpoints to db, various refactorings