Fix bug #4
Fix bug #2, #3