Added source code form rob, stripped unneeded parts