[modules] Module support code.

Warning: Contains evil reflective stuff. Very evil. And kinda nasty looking.