Refactored GPIO code
GPIO functions for hooking