TSAGE: Fix CID 1002385, 1002386, 1002388. Move some code from header to source file
TSAGE: Fix CID 1002392 and CID 1002387