fix bugs found by sebastian