Refactored device register function, added beacons API, and refactored models.js