code clean up, bug fixing,simple monitoring