add remote contract matcher and minor refactoring