Fixed errors after testing with Jens