formatting fixes, removing redundant code, regexp fix