Fix #21, code cleanliness improvements