Cleaned up code in MapToolState for readability