Merge pull request #281 from JohnEarnest/warning_cleanup

Cleaning up compiler warnings
fix #282: index checking for matrices
better fix
better yet