added checking of consistency of matrix and vector, added return codes for errors for main module