Cleaned up additional math errors due to poor function creation. I split one subnet function into three to clean the code up.