Fix bugs and change constructor to a single parameter.