Added copyright notices. Cleaned up some code.