First version to actually work; needs a lot more work and options