fix some errors and library utilization