Code cleanup. Removed some block nesting.