Refactoring for Octave 3.8.1 compatibility

Currently with these changes can run som_demo1 and som_demo2 without
error. However som_demo3 does not...