code improvements and cleanning