fixed some bugs from former commit; write tests! :P