Updated Template.cs with improved code and fixes

Added updated Binary Pattern Match function by wieschoo. Optimized BPM. Optimized class. Fixed documentation and input parameters of BPM due to a little mistake causing an error.