Added is_nil and tail functions; moved #defines to the end