Fixed some possible null references.
Improved some code actions.