Reduced variable scopes, added missing constructros