IntelliJ fixups

This removes the majority of the warnings reported by analyze
in IntelliJ

Change-Id: I0b4692e53e67eede50628399e218fa058f3410a5
Reviewed-on: http://review.couchbase.org/27679
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>