Module reloading fix.

Here is the module reloading code that unregisters and unbinds modules before they are reloaded.

This also fixes issue #258 and undoes 45ebebf. I merged it instead of rebasing, as rebasing made the commit look a bit confusing.