merge fix of isue github issue 143. Plus some minor stuff