added height fix
fixed height calculation
fixed null pointer exception
improved encapsulation