Completed conversion to local variables where applicable