fixed double call on EntrySec, added thread
code cleanup