various bug fixing, fixes #3