Removed factories, cleaned up code