Fixed for various memory issues