[FXOS-249] Perf optimization and defensive coding