Clean up and adjust cases

Use functions to clean up regex conditions
Catch more cases regarding comment lines
Change name of previous_line var to prev_line