Fix issue #18: Improve IP detection for client. Also make cache life configurable