Additional work for PR #18

Completed the work for PR #18. Apologies for the number of commits here, I didn't want to rebase and mess everything up.