Fairly major bug fixes for #132
Uncommented clean-up code for #132