Fixed errors and some minor issues