Fixes #1 #2 #3 also closes #4