refactor, fixes (#1106)