add instance checking stuff
Move some stuff to constructor declarations
Fix minor syntax issue
Incorporate changes and add unit tests