Moved the if(m_haslock) check to the top of the function for efficiency.