numerous typos/syntax error fixes, added some functionality to set a debug flag and use a
fixed RandomState