bug fixing, clean-up