Added more functionality to this. This is still work in progress!Y