Reorganized error checking
Improved variable names
Added bound to negative timeouts for upgrading a lock