Fixes #48, fixes #46, fixes #42, fixes #41, fixes #34, fixes #31