rework functions file, other changes too