Removed unused variables.
Actually give up on IO lock.
Avoid a few compiler warnings.