Initial script with bit twiddling functions