calc coords properly, margins fixed

Change-Id: Ic3b107f80cd07ff50567d0591fabbad0c0b546f7