Updated stat handling and signal handling
Added a reader thread so signals don't affect code that is running
Also, reorganized code