Added debug prints support (selective en/disable)

Signed-off-by: TheCodeArtist <cvs268@gmail.com>
Modified threading logic for clean exit

Signed-off-by: TheCodeArtist <cvs268@gmail.com>