Cleaned up and removed unnused code