More readable implementation of readObject and buffer loading