Fix #3, and minor cleanup