added getopt, was posix anyway
fixed circular buffer