Various refactoring: - reduced repetition with conversation message handling - made some functions internal