Cleaned up some common code