Fix bug #18
Fix bug #14
Fix bug #17