Updated code style and added an optional ANRListener.