started to reduce globals, set signal handlers after everything used in them initialized