added debug flags
bugfixes and removing deprecated method
fixed reference to public js files and using env var for debugging