cleanup code, remove some unused functions