handle exceptions
simplify
improve scanning of table layout
simplify some more