Fixed flaws pointed out by @daqing in #31