Adding an rgba calculation function
Oops... bugfix on the previous commit
Adding comments and code improvements