Fixed #51, couple of other fixes