DDBNEXT-1005: Refactoring Javascript code (clean up)