Code cleanup

Safe stylistic changes - variable names (removed m prefix, added _ to
all member variables), qualifiers (const, readonly), usings, removed
commented out code, removed unreachable code (within reason), removed
unnecessary checks for null, fixed incorrect usage of "as" operator
(typecast errors preferable to null reference errors).

Checked with static analyzer - the code is functionally equivalent.