Try to improve GPIO speed by calling gpio.setup less

This version should cache already-setup pins in an object, and only setup
again if the direction changes, or if the pin is not cached as exported.
Additionally, this version adds a handler for the process 'exit' event, which
should unexport all pins when the app is killed or exited.