In need of more clean up but this is a start