Fixed memory partitioning so it mostly works now. Still needs cleaning up though