Added border and offset commands; restructed code