Some cleaning up, still some performance enhancement to be done