various fixes and some cleanup

various fixes and some cleanup

closes #901
closes #902
closes #903