apply bug fixes from Adrian Granado in previous commit to other affected application files