Fixes #1 #2 #4 #5