fix some things for #31
merge and add more stuff on #31, finishing better fix