Simplified cache computation logic

I unified position/alpha level calculation into one method. Hope this
will make it easier to read