Added common class
Moved functions to common class, misc fixes