identified some bugs. marked with FIXME