Moved the automatic decision for gpt or mbr towards the beginning, to assure the partition_table variable is set to either gpt or mbr.
Added missing "if" and "'" statements.