improved tableview drawing

and some bug fixes