Introduce production and development mode

Some functional fixes and cleanup. Gruntfile.js is as recent as I could make it but some dependencies may be missing.