Issue 8

Resolves #8 and fixes some other issues pointed out elsewhere on the internet