this fixes #9, #8, #7, #6, #5