Finish table generation

Changed table generation behaviour
Fixed table generation bugs
Improved variable inserter/counter
Improved expression parser
Cleaned code