Refactores WFCR code - made it more Matlab-looking (including 1-based indexes)