Bug fixes to deal with records keyword