Write up piece-handling functions.