Code Clean up and regex fix for "no repeats" error (reverted from commit 8ecd5a196db7c4ef235a87c6110e91596bf5ca34)