Nanoscale phenomena in ferroelectric thin films