fixed Issue #52 and minor bug