Blockchain bugfix & use generics

- Use DBIterator.hasNext() function to check if DB is empty instead of looking at index.size() which will always be empty at initialization.
- Add missing generics to HashMap in TrackTrie
- Update Cache to use the same ByteArrayWrapper. Because a byte[] should not be used as a unique key in a map. As discussed here: http://stackoverflow.com/a/1058169 - Currently it works fine but might cause issues in the future.