handling login/logout redirects

I have a couple issues with the way WordPress handles redirects on login and logout.

Standard behaviour is:

login: /wp-login.php (with no redirect_to url) -> /wp-admin.php 
logout: /wp-admin.php -> /wp-login.php

What want is:

login: /wp-login.php (with no redirect_to url) -> homepage
logout: /wp-admin.php -> homepage

Would prefer a coded solution please. It helps me to learn and understand how WordPress works.

Thank you

Solutions Collecting From Web of "handling login/logout redirects"