[Blue-HD] pvrbg fix and moved some code around