Modified replace calls, added finally to test application