Improve relbalance-fun and management of records