fixes #223,#330,#357