A few bug fixes after the first commit. Added correct calls to save
stimulus via stimdb.