Fixed several code issues.