Revert "Slight refactoring, improved parsing"

This reverts commit d9de6869f0142eb2796a9a99e3e366d29db3bb64.
Revert "Revert "Slight refactoring, improved parsing""

This reverts commit a2e71073e5bdf979548b1aca99980f8a3542ccaf.
Restored main