Cleaned up code. Still failing on some objects