[refactor] Moving code around to make it more maintainable.
[feature] Additional regex to spot square brackets.