How to do a full factory reset and clean the phone completely? I've been flashing my LG Optimus L7 numerous times with various Custom ROMs and now I'd like to return to the official firmware.

I've factory reset my phone, flashed the v20D official firmware with KDZ tool and then I did another factory reset. However, I've read that the factory reset only wipes /data and /cache folders (user-accessible data), while /system and /boot remains the same. The questions:


I've flashed the official firmware using the KDZ tool with the EMERGENCY phone mode. After flashing, some of the old settings remained which were gone after a factory reset. As I understand, flashing the phone with a firmware doesn't wipe /system or /boot, right? Therefore some of the files from the previous custom ROM remain.
What should I do now to fully clean my phone from all custom ROMs? I've already flashed the original firmware and did several factory resets, but I know the reset doesn't touch /system and /boot, for example. How do I completely clean my phone? Is it even possible?
As the firmware resides in /system, flashing a firmware obviously overwrites that partition. /boot is usually involved here as well. Whether the two get "wiped" is a different question; but as otherwise things could get "mixed", which might cause unwanted side-effects, I'd say they are (I'm not 100% sure with this). So in these two partitions, nothing of the previously installed firmware should remain.

That's different for the other partitions of your device. So usually, /data is not touched by the flashing process, but of course it will be touched once the new system boots up (it e.g. needs to initialize the dalvik cache for the newly installed system apps, which is located in /data/dalvik-cache). For the /cache partition (holding the application cache) it's similar: It usually is not touched by the flashing process, but used normally afterwards. Hence it's a good idea to wipe these two (Cache and Dalvik Cache) when installing a different ROM. It might not always be required, but it doesn't hurt.

A factory-reset in principle is a combination of the two: it wipes the /cache and /data Partitions. So other than the manual wipe of the caches from a custom recovery, it also removes all user data (including the user-installed apps).

Note: Don't confuse a "wipe" with a "safe erase": with the right tools, data still might be recoverable following a wipe.

With this on your mind, your second question becomes obsolete: if you just want a clean system for yourself, this wish is already granted. If, on the other hand, you did these steps to sell your device, there's always the point of what could be restored. For a "safe erase", you might want to take a look at special tools like Nuke My Phone / Nuke My Tablet, which overwrite everything with "garbage data", and finalize this process with a factory-reset.