refractor code. fix several minor issues like self sharing, empty trigger search, height issues etc.