added main memory implementation, several changes to overall code