changed the way serial is exported
moved methods into prototypes