bug fixes, hopefully ok!