cleanup and bug #421 fix