fixed bugs reported by jkaberg.