init commit. Defensive coding improvements added. Add extra credit copy function