Merge lastest

1) Moved some variables and methods to improve the design
2) Tested first part of updateTable method and related methods, added some test cases, and fixed some bugs.