Some code optimized, startup routine has unnecessary register setting, weird delays all over the place. Data read cleaned up for REG_PIOD_PDSR stuff.