First draft.  Need to clean up code.