Fixed #11.
Fixed #4.
Fixed #15.
Fixed #13.
Fixed #12.
Fixed #3.  Also converted some tabs to spaces.