lots of code optimization.. and tests.. and more..