Refactorization and cleanup. Readme update.