fixes from samchen2009
compiles circa 2014-08-28