Optimalization of ArrayList put and remove methods