fixes #23, #21, #19, #12