Modified Object.removeObject() to check for endpoints referencing it before deleting
More refactoring. Created a few 'Helper Methods' to reduce duplicate code