Fixes #21, #23, #24, #25