Corrected a couple of serious bugs

Corrected a error when loading in BISM mode, and also added better
controll for injection, removing and replacing javascript files.