Most of the code, need to document and do finer testing. Need to join examples into one.