Fix nullpointer exception when script is garbage collected, plus some cleanup and simplification.
Fix nullpointer exception when script is garbage collected, plus some cleanup and simplification.

ashwinrayaprolu1984/ringojs,ashwinrayaprolu1984/ringojs,ringo/ringojs,Transcordia/ringojs,ashwinrayaprolu1984/ringojs,ringo/ringojs,ringo/ringojs,ashwinrayaprolu1984/ringojs,Transcordia/ringojs,oberhamsi/ringojs,oberhamsi/ringojs,Transcordia/ringojs,oberhamsi/ringojs,Transcordia/ringojs,ringo/ringojs