Start removing jQuery dependency

+ a little refactoring