Corrected error checking; proper power of two check implemented