Converted tabs to 4-spaces indentation and changed deprecated has_key() calls