Fixed for V0.10.0 (Also backwards compatible with 0.8 and before)

Cleaned up to be JSLinted/JSHinted/"use strict".   (Sorry, this does makes tracking rev's a little harder since it is a massive patch; but it was a lot easier to follow and understand what the code was doing when everything was a bit cleaner (for me) -- I'll understand if all you want to do is pick out the fixes).