fixed up width/height calcs, fixed sorting