Merge in r52's work 

Merge in r52's current changes that make the plugin more 64bit friendly and also improves some general mistakes.
Merging this in before i go changing lumps of code