Grunt integration, some code refactoring