Added checkin endpoints, various code refactoring