Fixes for compilation problem due to TOperationState
Code cleanup