fix undefined vars in extension, style cleanup