code cleanup and minor bugs squashed...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>