some cleanup
moved utility functions to separate header; need to rethink random matrix generation