Optimize kernel part 1: Add frandom

Also trim trailing white spaces

Change-Id: I1c4aa54e3ee583ae0cd68a23f146a8070e1ce31a