Removing unreachable code.
Fixing resource leaks and null pointer issues.