added some more logging
fixed a bug caused by my own stupidity