Moved some table parsing logic into subroutines