Cleaned up more magic numbers, and replaced break statements with boolean conditions