Fixed #19, added logging