Ported more changes from old repo