bugfix and improvements

API cleanup and possible bugfix (regarding the timing of interruption and setting a hander).