Incorporate application code from https://gist.github.com/gvanrossum/291bfcfe70d2f9582331