config: move optparse import to top
config: make parsed command line options accessible everywhere
implement daemonize
add pidfile handling