Some shared functions.