Completed version, fixed bugs. Just needs testing.