Fixing allocation related bugs
Everything works now