moved over some common parts
merged master