Added some helper functions and re-organized according to object class