Added logging and fixed regex issues.