Fixed bug #66: Added more checks for focusedElem being null/undefined. This prevents exceptions when there isn't proper focus.