fixes issues 346, 334, 333, 320, 322, 323