Code clean up, add hangup handler

Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>