Move code into api.js
Moved constructors to prototypes
Merge branch 'just_objects'