Use better object inheritance for location components

Inspired from http://stackoverflow.com/a/7786090