Fixed error logging in State, fixed minor bugs in bpm_states