Finished basic functionality

A little bit of tidying up would be helpful, but not necessary.
Better error/failure messages could also be added but this is a
secondary project so that care may not go into it.