some bug fixes to prior commit, sorry