Several changes and function renaming