fixes issue #1, #2, #4