cleap up and minor bug fixes