fixed a bunch of bugs from Imke