Fixes #40, fixes #39, fixes #38