Added grunt bake functionality and reordered some code