Fixed a wrong table reference, and tiny little bugs