I just discovered this module. It should be used instead of the haphazard incomplete handling I implemented myself.