Refactor table drawing functions fixes #5