bug fixes in duties with new stored procedure trimming dead branches