various bug fixing.