Re-organize code; update the copyright