Only open the pid file if we're actually going to use it
Zero out unused members of the epoll_event struct
Check for failure of realloc
Move variables into more specific scopes