Remove Dupe Code and Add More Error Checking

Again need to test this.