Bugfixes and improved regexes