Minor error corrections and some cleanup