awful half merge thing with some changes from hsdev
merge stuff