some bug fixes, tightening up