Fixed certain bugs that may cause segment error -- the last object of 'int a[100];' is a[99], a[0~99], not a[100]. And added a small delay to main loop to stop it from crashing in some way.