Fixed advising functions and made some restructurings.