added new insertion state functionality. haven't debugged yet.
fixed some minor bugs
added posterior probability calculation function
added matlab wrapping functions
cleaning up before new changes
cleaning up and merging
added files to help with matlab compatibility