Cleaned up code in regexp, minor changes to imports etc.