fixed #35 and minor cleanup