Changed a couple functions to enable optimization. 10% performance boost