Fixed some bugs and added accessors.