added more hooks for python mode