Initial commit of library.

Works well. Needs some clean up.