Issue 13

Bug fix for bug #13

This also removes some unused code.