Some bug fix identified by David K! --kazu