Fixes

fixed up some issues from first automated run, also, cleaned up some
code