fix #1, fix#2, resolves #4