Some changes. Bug fixing and clean up.