Major improvement to tab and conditional logic code to improve performance

Signed-off-by: Elliot Condon <e@elliotcondon.com>