This fixes #4, #5, #6