fixed replace regex and some other corresponding problems