code cleanup

Few random code cleanup changes.Efficiency improvements, removal of redundant activities, removal of deprecated functions.

Signed-off-by: Nilkamal Weerasinghe <wnilkamal@yahoo.com>