Moved few functions to foreign/records